package net.mikoo.seals.api.model.install;

import java.text.SimpleDateFormat;

import net.mikoo.seals.api.model.BaseResponse;
import net.mikoo.seals.common.enums.InstallTypeEnum;
import net.mikoo.seals.model.Devices;
import net.mikoo.seals.model.Install;
import net.mikoo.seals.model.Person;

public class InstallVerifyDetailResponse extends BaseResponse {

	private Long installId;
	
	private Long partyId;
	
	private String partyName;
	
	private String portrait;
	
	private String position;
	
	private String applyTime;
	
	private String sealName;
	
	private String devicesCode;
	
	private String typeName;

	public Long getInstallId() {
		return installId;
	}

	public void setInstallId(Long installId) {
		this.installId = installId;
	}

	public Long getPartyId() {
		return partyId;
	}

	public void setPartyId(Long partyId) {
		this.partyId = partyId;
	}

	public String getPartyName() {
		return partyName;
	}

	public void setPartyName(String partyName) {
		this.partyName = partyName;
	}

	public String getPortrait() {
		return portrait;
	}

	public void setPortrait(String portrait) {
		this.portrait = portrait;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public String getApplyTime() {
		return applyTime;
	}

	public void setApplyTime(String applyTime) {
		this.applyTime = applyTime;
	}

	public String getSealName() {
		return sealName;
	}

	public void setSealName(String sealName) {
		this.sealName = sealName;
	}

	public String getDevicesCode() {
		return devicesCode;
	}

	public void setDevicesCode(String devicesCode) {
		this.devicesCode = devicesCode;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}
	
	public void setData(Install install) {
		
		if(install == null) {
			return ;
		}
		
		this.installId = install.getInstallId();
		this.partyId = install.getPartyId();
		
		Person person = install.getPerson();
		if(person != null) {
			this.partyName = person.getName();
			this.portrait = person.getPortrait();
			this.position = person.getPosition();
		}
		Devices devices = install.getDevices();
		if(devices != null) {
			this.devicesCode = devices.getDevicesCode();
			if(devices.getSeal() != null) {
				this.sealName = devices.getSeal().getSealName();
			}
		}

		if(install.getApplyTime() != null) {
			this.applyTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(install.getApplyTime());
		}
		
		InstallTypeEnum installType = InstallTypeEnum.getByCode(install.getInstallType());
		if(installType != null) {
			this.typeName = installType.getMessage();
		}
	}
}
